package com.example.exception;


import lombok.Data;

@Data
public class Result {

    /* 状态、信息 */
    private int code;//200
    private String message;
    private Object data;

    /**
     * @Description: 返回成功状态对象
     * @param: message
     * @return: cn.com.niit.musicserver.common.Result
     **/
    public static Result success(String message){
        Result r = new Result();
        r.setCode(200);
        r.setMessage(message);
        return r;
    }

    public static Result success(String message, Object data){
        Result r = new Result();
        r.setCode(200);
        r.setMessage(message);
        r.setData(data);
        return r;
    }

    /**
     * @Description: 返回失败状态对象
     * @param: code
     * @param: message
     * @return: cn.com.niit.musicserver.common.Result
     **/
    public static Result faile(int code, String message){
        Result r = new Result();
        r.setCode(code);
        r.setMessage(message);
        return r;
    }

    public static Result faile(String message){
        Result r = new Result();
        r.setCode(999999);
        r.setMessage(message);
        return r;
    }
    
    /**
     * @Description: 返回错误信息
     * @param: code
     * @return: Result
     **/
//    public static Result faile(ExceptionCodeEnum code) {
//        Result r = new Result();
//        r.setCode(code.getResCode());
//        r.setMessage(code.getResDesc());
//        return r;
//    }
}